Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms

Public Class FrmCrBaoCaoLaiLo
    Private thang, nam As String
    Private customerReport As ReportDocument

    Delegate Sub WaitDelegate()

    Private Sub FrmCrBaoCaoLaiLo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        globalVariale.runWaitting = True
        Dim wd As New WaitDelegate(AddressOf moduleWaitting.runningWait)
        wd.BeginInvoke(Nothing, Nothing)
        Dim sqlQuery As String
        sqlQuery = " SELECT left(t1.ma_taikhoan,1) as nhom ,t1.ma_taikhoan, t2.ten_tieukhoan as ten_taikhoan,t1.psnovn as psno,t1.pscovn as psco "
        sqlQuery += "  FROM tbl_dot_temp_toncdtk as t1,tbl_tieukhoan as t2 "
        sqlQuery += " where t1.ma_taikhoan=t2.ma_tieukhoan and t1.recycleID='" & nam & thang & "' "
        sqlQuery += " AND t1.ma_taikhoan IN ( '711','811','511','5111','511K','511M','515','641','6411','6412','6413','6414','6415','6416','6417','6418','642','6421','6422','6423','6424','6425','6426','6427','6428','635','632' ) "
        sqlQuery += " ORDER BY t1.ma_taikhoan "
        Dim reportPath = Application.StartupPath & "\" & "crBaoCaoLaiLo.rpt"
        customerReport = New ReportDocument()
        customerReport.Load(reportPath)
        customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
        customerReport.SetParameterValue("month", thang)
        customerReport.SetParameterValue("year", nam)
        customerReport.SetParameterValue("company", globalVariale.COMPANY)
        customerReport.SetParameterValue("address", globalVariale.ADDRESS)
        Me.CrNXTTongHopview.ReportSource = customerReport
        globalVariale.runWaitting = False
    End Sub

    Public Sub setThang(ByVal s As String)
        thang = s
    End Sub

    Public Sub setNam(ByVal s As String)
        nam = s
    End Sub

End Class
